<template>
	<view class="d-kuan">
		
			<uv-navbar height="50" leftText="返回" :fixed="false" :title="title" :safeAreaInsetTop="true" style="">
				<template v-slot:left>
					<view class="uv-nav-slot">
						<uv-icon name="arrow-left" size="24" @click="fanhui"></uv-icon>
						<!--uv-line direction="column" :hairline="false" length="16" margin="0 8px"></uv-line>
						<uv-icon name="home" size="24"></uv-icon-->
					</view>
				</template>
				<template v-slot:right>
					<view class="uv-nav-slot">
						<!--uv-icon name="arrow-right" size="24"></uv-icon>
						<uv-line direction="column" :hairline="false" length="16" margin="0 8px"></uv-line-->
						<uv-icon name="home" size="24" @click="shouye"></uv-icon>
					</view>
				</template>
			</uv-navbar>

		
		
	</view>
</template>
<script>
import { getRequest,postRequest } from '@/utils/wxRequest.js'
import Api from '@/utils/api.js'
//import duixin from '@/utils/config.js'

export default {
  name: 'Dfanhui',
  props: {
    title: {
      type: String,
      default: ''
    }
  },
  // 组件挂载时执行
  mounted() {
  },
 
  data() {
    return {
      
    };
  },
  computed: {
	
   
  },
  
  methods: {
    fanhui(){
		// 返回上一页，若没有则返回首页（带健壮兜底）
		try {
			// 优先判断页面栈是否有上一页
			const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : [];
			if (Array.isArray(pages) && pages.length > 1) {
				uni.navigateBack({ delta: 1 });
				return;
			}
		} catch (e) {
			// 忽略异常，继续走首页兜底
		}
		// 无历史或返回失败，跳首页（优先 switchTab，失败则 reLaunch）
		try {
			uni.switchTab({
				url: '/pages/index/index',
				fail: (err) => {
					console.warn('switchTab 到首页失败，尝试重启到首页:', err);
					try { uni.reLaunch({ url: '/pages/index/index' }); } catch (e2) {}
				}
			});
		} catch (error) {
			try { uni.reLaunch({ url: '/pages/index/index' }); } catch (e3) {}
		}
    },
	shouye(){
		// 直接去首页（优先 switchTab，失败则 reLaunch）
		try {
			uni.switchTab({
				url: '/pages/index/index',
				fail: (err) => {
					console.warn('switchTab 到首页失败，尝试重启到首页:', err);
					try { uni.reLaunch({ url: '/pages/index/index' }); } catch (e2) {}
				}
			});
		} catch (error) {
			try { uni.reLaunch({ url: '/pages/index/index' }); } catch (e3) {}
		}
	}
	

  }
}
</script>

<style scoped lang="scss">
    @mixin flex($direction: row) {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: $direction;
	}
	.uv-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: #dadbde;
		padding: 3px 7px;
		opacity: 0.8;
		line-height: 60px;
	}
</style>